/* const parent = {
  get value() {
    return "19Qingfeng";
  },
};

const obj = {
  name: "wang.haoyu",
};
const proxy = new Proxy(parent, {
  // get陷阱中target表示原对象 key表示访问的属性名
  get(target, key, receiver) {// receiver 为了正确传递上下文
    //receiver并不一定必须等于代理对象，还有可能是待获取属性的那个对象
    console.log(receiver === obj);
    console.log(this);
    return target[key];
  },
});

// 设置obj继承与parent的代理对象proxy
Reflect.setPrototypeOf(obj, proxy);

// log: false
console.log(obj.value, obj.name);
 */

const parent = {
  name: '19Qingfeng',
  get value() {
    return this.name;
  },
};

const handler = {
  get(target, key, receiver) {
    return Reflect.get(target, key, receiver);
    // 这里相当于 
    return target[key]
  },
};

const proxy = new Proxy(parent, handler);

const obj = {
  name: 'wang.haoyu',
};

// 设置obj继承与parent的代理对象proxy
Reflect.setPrototypeOf(obj, proxy);

// log: false
console.log(obj.value);

